<template>
    <div>
      <el-dialog
        :title="form.title"
        width="800px"
        class="icon-dialog"
        :visible.sync="show"
        :before-close="closeForm"
        append-to-body
        @open="open"
      >
        <el-form
          ref="form"
          :size="size"
          :model="form"
          :rules="rules"
          :label-width="$store.getters.device !== 'mobile'?'16%':'90px'"
        >
        <table
          class="table table-bordered"
          align="center"
          width="100%"
          style="word-break:break-all; margin-bottom:50px;  font-size:13px;"
        >
          <tbody>
            <tr>
              <td class="title" width="100">用户：</td>
              <td>
                {{ form.name }}
              </td>
            </tr>
            <tr>
              <td class="title" width="100">手机号：</td>
              <td>
                {{ form.tel }}
              </td>
            </tr>
            <tr>
              <td class="title" width="100">总计：</td>
              <td>
                {{ form.total }}
              </td>
            </tr>
            <tr>
              <td class="title" width="100">支付类型：</td>
              <td>
                {{ form.pay_subject }} 
              </td>
            </tr>
            <tr>
              <td class="title" width="100">支付时间：</td>
              <td>
                {{ form.pay_time }} 
              </td>
            </tr>
            <tr>
              <td class="title" width="100">审核状态：</td>
              <td>
                {{ form.status == 1?'已批准': '待审核' }}
              </td>
            </tr>
            <!-- <tr>
              <td class="title" width="100">备注</td>
              <td>
                <el-input v-model="form.douremark" auto-complete="off" clearable placeholder="请输入审核备注" />
              </td>
            </tr> -->
          </tbody>
        </table>
        </el-form>
        <div slot="footer" class="dialog-footer" v-if="form.status == 0">
          <el-button :loading="loading" type="primary" @click="submit(1)">
            <span v-if="!loading">审核通过</span>
            <span v-else>提 交 中...</span>
          </el-button>
          <el-button :loading="loading" type="danger" @click="submit(2)">
            <span v-if="!loading">审核驳回</span>
            <span v-else>提 交 中...</span>
          </el-button>
          <el-button @click="closeForm">取 消</el-button>
        </div>
        <div slot="footer" class="dialog-footer" v-else>
          <el-button @click="closeForm">关 闭</el-button>
        </div>
      </el-dialog>
    </div>
  </template>
  <script>
  import ImagesUpload from '@/components/common/ImagesUpload.vue'
  export default {
    name: 'Servicecategoryupdate',
    components: {
      ImagesUpload
    },
    props: {
      show: {
        type: Boolean,
        default: false
      },
      opentype: {
        type: String,
        default: 'add'
      },
      size: {
        type: String,
        default: 'small'
      },
      info: {
        type: Object
      }
    },
    data() {
      return {
        dialogtitle: '',
        servicedeliverymodearray:[],
        form: {
          title: '',
          ptype: 2,
          status: 1
        },
        pids: [],
        ptypearray: [],
        loading: false,
        rules: {
          name: [{
            required: true,
            message: '名称不能为空',
            trigger: 'blur'
          }]
        }
      }
    },
    methods: {
      open() {
        if (this.opentype == 'update') {
          this.dialogtitle = '修改'
          this.form = this.info
          if (this.info.pid == '0') {
            this.$delete(this.info, 'pid')
          }
        } else {
          this.dialogtitle = '添加'
          this.form = {
            ptype: 2,
            deliverymode: 1,
            status: 1
          }
          // console.log(this.form);
        }
      },
      submit(status) {
        this.$refs['form'].validate(valid => {
          if (valid) {
            this.loading = true;
            this.form.status = status;
            this.$api.post('/wyorder/update', {id: this.form}).then(res => {
              this.$message({
                message: res.msg,
                type: 'success'
              })
              this.$emit('refesh_list')
              this.closeForm()
            }).catch(() => {
              this.loading = false
            })
          }
        })
      },
      normalizer(data) {
        if (data.children && !data.children.length) {
          delete data.children
        }
        return {
          id: data.val,
          label: data.key,
          children: data.children
        }
      },
      closeForm() {
        this.$emit('update:show', false)
        this.loading = false
        if (this.$refs['form'] !== undefined) {
          this.$refs['form'].resetFields()
        }
      }
    }
  }
  </script>
  